package com.zhuojy.equity.mall.admin.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhuojy.equity.mall.admin.common.entity.Accounts;
import com.zhuojy.equity.mall.admin.common.entity.TSubject;
import com.zhuojy.equity.mall.admin.common.pojo.JsonResult;
import com.zhuojy.equity.mall.admin.dal.mapper.TSubjectMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@RequiredArgsConstructor
public class TSubjectService extends ServiceImpl<TSubjectMapper, TSubject> {
    /**
     * 收支科目条查分页
     * @param tSubject
     * @param pageNum
     * @param pageSize
     * @return
     */
    public JsonResult findSubjectPagination(TSubject tSubject, Integer pageNum, Integer pageSize) {
        Page<TSubject> page = new Page<>(pageNum,pageSize);
        IPage<TSubject> tSubjectIPage =  this.baseMapper.findSubjectPagination(tSubject,page);
        return JsonResult.success(tSubjectIPage.getRecords(),tSubjectIPage.getTotal());
    }

    /**
     * 收支科目删除
     * @param id
     */
    public void deleteSubject(Integer id) {
        this.baseMapper.deleteById(id);
    }

    /**
     * 收支科目新增
     * @param tSubject
     */
    public void addSubject(TSubject tSubject) {
        this.baseMapper.insert(tSubject);
    }
}
